set more off
clear

use anes_timeseries_cdf_stata12.dta, clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0830 (0 9=.), gen(AIDB)
replace PARTY=PARTY*VCF0009z
replace AIDB=AIDB*VCF0009z
keep if inlist(VCF0004,1984,1988,1992,1996,2000,2004,2008,2012)
keep if VCF0017<4
ktau PARTY AIDB if VCF0004==1984
svret r, keep(r(tau_b) r(p))
gen year=1984
gen question=1
saveold kendallw.dta, replace

forval x = 1988(4)2012{
clear

use anes_timeseries_cdf_stata12.dta, clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0830 (0 9=.), gen(AIDB)
replace PARTY=PARTY*VCF0009z
replace AIDB=AIDB*VCF0009z
keep if inlist(VCF0004,1984,1988,1992,1996,2000,2004,2008,2012)
keep if VCF0017<4
ktau PARTY AIDB if VCF0004==`x'
svret r, keep(r(tau_b) r(p))
gen year=`x'
gen question=1
append using kendallw.dta
saveold kendallw.dta, replace
}

forval x = 1984(4)2012{
clear

use anes_timeseries_cdf_stata12.dta, clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0838 (1=4) (2=3) (3=2) (4=1) (0 9=.), gen(ABORTION)
replace PARTY=PARTY*VCF0009z
replace ABORTION=ABORTION*VCF0009z
keep if inlist(VCF0004,1984,1988,1992,1996,2000,2004,2008,2012)
keep if VCF0017<4
ktau PARTY ABORTION if VCF0004==`x'
svret r, keep(r(tau_b) r(p))
gen year=`x'
gen question=2
append using kendallw.dta
saveold kendallw.dta, replace
}

forval x = 1984(4)2012{
clear

use anes_timeseries_cdf_stata12.dta, clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0809 (0 9=.), gen(JOBS)
replace PARTY=PARTY*VCF0009z
replace JOBS=JOBS*VCF0009z
keep if inlist(VCF0004,1984,1988,1992,1996,2000,2004,2008,2012)
keep if VCF0017<4
ktau PARTY JOBS if VCF0004==`x'
svret r, keep(r(tau_b) r(p))
gen year=`x'
gen question=3
append using kendallw.dta
saveold kendallw.dta, replace
}

forval x = 1984(4)2012{
clear

use anes_timeseries_cdf_stata12.dta, clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0806 (0 9=.), gen(HEALTH)
replace PARTY=PARTY*VCF0009z
replace HEALTH=HEALTH*VCF0009z
keep if inlist(VCF0004,1984,1988,1992,1996,2000,2004,2008,2012)
keep if VCF0017<4
ktau PARTY HEALTH if VCF0004==`x'
svret r, keep(r(tau_b) r(p))
gen year=`x'
gen question=4
append using kendallw.dta
saveold kendallw.dta, replace
}

forval x = 1984(4)2012{
clear

use anes_timeseries_cdf_stata12.dta, clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0843 (0 9=.), gen(DEFENSE)
replace PARTY=PARTY*VCF0009z
replace DEFENSE=DEFENSE*VCF0009z
keep if inlist(VCF0004,1984,1988,1992,1996,2000,2004,2008,2012)
keep if VCF0017<4
ktau PARTY DEFENSE if VCF0004==`x'
svret r, keep(r(tau_b) r(p))
gen year=`x'
gen question=5
append using kendallw.dta
saveold kendallw.dta, replace
}
 
forval x = 1984(4)2012{
clear

use anes_timeseries_cdf_stata12.dta, clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0839 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1) (0 9=.), gen(SPENDING)
replace PARTY=PARTY*VCF0009z
replace SPENDING=SPENDING*VCF0009z
keep if inlist(VCF0004,1984,1988,1992,1996,2000,2004,2008,2012)
keep if VCF0017<4
ktau PARTY SPENDING if VCF0004==`x'
svret r, keep(r(tau_b) r(p))
gen year=`x'
gen question=6
append using kendallw.dta
saveold kendallw.dta, replace
} 


set more off
clear

use "anes_timeseries_cdf_stata13.dta", clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0830 (0 9=.), gen(AIDB)
replace PARTY=PARTY*VCF0009z
replace AIDB=AIDB*VCF0009z
keep if VCF0017<4
ktau PARTY AIDB if VCF0004==2016
svret r, keep(r(tau_b) r(p))
gen year=2016
gen question=1
append using "kendallw.dta"
saveold kendallw.dta, replace

clear

use "anes_timeseries_cdf_stata13.dta", clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0838 (1=4) (2=3) (3=2) (4=1) (0 9=.), gen(ABORTION)
replace PARTY=PARTY*VCF0009z
replace ABORTION=ABORTION*VCF0009z
keep if VCF0017<4
ktau PARTY ABORTION if VCF0004==2016
svret r, keep(r(tau_b) r(p))
gen year=2016
gen question=2
append using kendallw.dta
saveold kendallw.dta, replace

clear

use "anes_timeseries_cdf_stata13.dta", clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0809 (0 9=.), gen(JOBS)
replace PARTY=PARTY*VCF0009z
replace JOBS=JOBS*VCF0009z
keep if VCF0017<4
ktau PARTY JOBS if VCF0004==2016
svret r, keep(r(tau_b) r(p))
gen year=2016
gen question=3
append using kendallw.dta
saveold kendallw.dta, replace

clear

use "anes_timeseries_cdf_stata13.dta", clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0806 (0 9=.), gen(HEALTH)
replace PARTY=PARTY*VCF0009z
replace HEALTH=HEALTH*VCF0009z
keep if VCF0017<4
ktau PARTY HEALTH if VCF0004==2016
svret r, keep(r(tau_b) r(p))
gen year=2016
gen question=4
append using kendallw.dta
saveold kendallw.dta, replace

clear

use "anes_timeseries_cdf_stata13.dta", clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0843 (0 9=.), gen(DEFENSE)
replace PARTY=PARTY*VCF0009z
replace DEFENSE=DEFENSE*VCF0009z
keep if VCF0017<4
ktau PARTY DEFENSE if VCF0004==2016
svret r, keep(r(tau_b) r(p))
gen year=2016
gen question=5
append using kendallw.dta
saveold kendallw.dta, replace
 

use "anes_timeseries_cdf_stata13.dta", clear
recode VCF0301 (0=.), gen(PARTY)
recode VCF0839 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1) (0 9=.), gen(SPENDING)
replace PARTY=PARTY*VCF0009z
replace SPENDING=SPENDING*VCF0009z
keep if VCF0017<4
ktau PARTY SPENDING if VCF0004==2016
svret r, keep(r(tau_b) r(p))
gen year=2016
gen question=6
append using kendallw.dta
saveold kendallw.dta, replace

saveold Figure01.dta, replace


set more off
clear

use anes_timeseries_2020_stata_20210324_12.dta, clear
recode V201231x (-9 -8 0=.), gen(PARTY)
recode V201258 (-9 -8 99 0 9=.), gen(AIDB)
replace PARTY=PARTY*V200010a
replace AIDB=AIDB*V200010a

ktau PARTY AIDB
svret r, keep(r(tau_b) r(p))
gen year=2020
gen question=1
append using "Figure01.dta"
saveold Figure01_2020.dta, replace

clear

use anes_timeseries_2020_stata_20210324_12.dta, clear
recode V201231x (0=.), gen(PARTY)
recode V201336 (1=4) (2=3) (3=2) (4=1) (0 9 5 -9 -8 =.), gen(ABORTION)
replace PARTY=PARTY*V200010a
replace ABORTION=ABORTION*V200010a

ktau PARTY ABORTION
svret r, keep(r(tau_b) r(p))
gen year=2020
gen question=2
append using Figure01_2020.dta
saveold Figure01_2020.dta, replace

clear

use anes_timeseries_2020_stata_20210324_12.dta, clear
recode V201231x (0=.), gen(PARTY)
recode V201255 (0 9 -9 -8 99=.), gen(JOBS)
replace PARTY=PARTY*V200010a
replace JOBS=JOBS*V200010a

ktau PARTY JOBS
svret r, keep(r(tau_b) r(p))
gen year=2020
gen question=3
append using Figure01_2020.dta
saveold Figure01_2020.dta, replace

clear

use anes_timeseries_2020_stata_20210324_12.dta, clear
recode V201231x (0=.), gen(PARTY)
recode V201252 (-9 -8 99 0 9=.), gen(HEALTH)
replace PARTY=PARTY*V200010a
replace HEALTH=HEALTH*V200010a

ktau PARTY HEALTH
svret r, keep(r(tau_b) r(p))
gen year=2020
gen question=4
append using Figure01_2020.dta
saveold Figure01_2020.dta, replace

clear

use anes_timeseries_2020_stata_20210324_12.dta, clear
recode V201231x (0=.), gen(PARTY)
recode V201249 (0 -9 -8 99 9=.) , gen(DEFENSE)
replace PARTY=PARTY*V200010a
replace DEFENSE=DEFENSE*V200010a

ktau PARTY DEFENSE
svret r, keep(r(tau_b) r(p))
gen year=2020
gen question=5
append using Figure01_2020.dta
saveold Figure01_2020.dta, replace
 

use anes_timeseries_2020_stata_20210324_12.dta, clear
recode V201231x (0=.), gen(PARTY)
recode V201246 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1) (-9 99 0 9=.), gen(SPENDING)
replace PARTY=PARTY*V200010a
replace SPENDING=SPENDING*V200010a

ktau PARTY SPENDING
svret r, keep(r(tau_b) r(p))
gen year=2020
gen question=6
append using Figure01_2020.dta
saveold Figure01_2020.dta, replace

clear

use Figure01_2020.dta, clear
format r_p %9.3f

label define question 1 "Aid to blacks" 2 "Abortion" 3 "Jobs" 4 "Health Insurance" 5 "Defense Spending" 6 "Goverment Spending"
label values question question

sort question year

tab r_p

gen unit=.
replace unit=71.8 if year==1980
replace unit=72.1 if year==1984
replace unit=70.5 if year==1988
replace unit=74 if year==1992
replace unit=59.8 if year==1996
replace unit=60.5 if year==2000
replace unit=66.1 if year==2004
replace unit=63.7 if year==2008
replace unit=38 if year==2012
replace unit=50 if year==2016
replace unit=36.7 if year==2020

sort year

saveold Figure01.dta, replace